package com.flash.TAManagement.controller;

import com.flash.TAManagement.entity.Ta;
import com.flash.TAManagement.service.TaService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TaController {
    @Resource
    private TaService taService;


    @RequestMapping("/selectTa")
    public Map selectTa(int page,int limit,String businessTime,String dealType){
        System.out.println("这是查询测试");
        HashMap map = new HashMap();
        List<Ta> tas = taService.selectTa(page,limit,businessTime,dealType);
        int count = taService.selectTaCount();
        System.out.println(tas);
        map.put("code","0");
        map.put("msg","");
        map.put("count",count);
        map.put("data",tas);
        return map;
    }


    @RequestMapping("/insertTa")
    public String insertTa(Ta ta){
        System.out.println("添加测试用户" + ta);
        int i = taService.insertTa(ta);
        System.out.println(i);
        if (i==1){
            System.out.println("-------------------------------------------------------------");
            return "yes";
        }else {
            return "no";
        }
    }


    @RequestMapping("/deleteTa")
    public int deleteTa(String taId){
        System.out.println("删除服务类:"+taId);
        int i = taService.deleteTa(taId);
        System.out.println(i);
        return i;
    }

    @RequestMapping("/updateTa")
    @ResponseBody
    public int updateTa(Ta ta){
        System.out.println("这是修改");
        return taService.updateTa(ta);
    }
}
